
const Multer=require("koa-multer")
const path=require("path")
const storage=Multer.diskStorage({
    //保存路径
    destination:"./uploads/avatar",
    //名字
    filename:(req,file,cb)=>{
        cb(null,"avatar"+path.extname(file.originalname));
    }
})
 
const upload=Multer(
   //  {  dest:"./uploads/avatar" }
  {storage}
);
 const uploads=Multer( { dest:"./uploads/picture" })
//上传文件 本身就是中间件
const createupload=  upload.single("avatar")
 const createuploads=uploads.array("pictrue",9)
//上传文件
// const createupload=async (ctx,next)=>{
//     //找到对应的key字段
    
//      console.log(ctx.req.file)
//      ctx.body="成功"
// }
module.exports={createupload,createuploads}